home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLSRC.PAK / RADIOBUT.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  2.8 KB  |  120 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1991, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.5  $
  6. //
  7. // Implementation of class TRadioButton.  This defines the basic behavior for
  8. // all radio buttons.
  9. //----------------------------------------------------------------------------
  10. #pragma hdrignore SECTION
  11. #include <owl/pch.h>
  12. #if !defined(OWL_RADIOBUT_H)
  13. # include <owl/radiobut.h>
  14. #endif
  15. #if !defined(OWL_GROUPBOX_H)
  16. # include <owl/groupbox.h>
  17. #endif
  18. #if !defined(OWL_APPLICAT_H)
  19. # include <owl/applicat.h>
  20. #endif
  21.  
  22. #if defined(BI_COMP_BORLANDC)
  23. # include <bwcc.h>
  24. #endif
  25.  
  26. OWL_DIAGINFO;
  27.  
  28. #if !defined(SECTION) || SECTION == 1
  29.  
  30. DEFINE_RESPONSE_TABLE1(TRadioButton, TCheckBox)
  31.   EV_NOTIFY_AT_CHILD(BN_CLICKED, BNClicked),
  32. END_RESPONSE_TABLE;
  33.  
  34. //
  35. // constructor for a TRadioButton object
  36. //
  37. TRadioButton::TRadioButton(TWindow*        parent,
  38.                            int             id,
  39.                            const char far* title,
  40.                            int x, int y, int w, int h,
  41.                            TGroupBox*      group,
  42.                            TModule*        module)
  43. :
  44.   TCheckBox(parent, id, title, x, y, w, h, group, module)
  45. {
  46.   Attr.Style = WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON;
  47. }
  48.  
  49. //
  50. //
  51. //
  52. TRadioButton::TRadioButton(TWindow*   parent,
  53.                            int        resourceId,
  54.                            TGroupBox* group,
  55.                            TModule*   module)
  56. :
  57.   TCheckBox(parent, resourceId, group, module)
  58. {
  59. }
  60.  
  61. //
  62. // Return name of predefined BWCC or Windows radio button class
  63. //
  64. char far*
  65. TRadioButton::GetClassName()
  66. {
  67. #if defined(BI_COMP_BORLANDC)
  68.   if (GetApplication()->BWCCEnabled())
  69.     return RADIO_CLASS;
  70.   else
  71. #endif
  72.     return "BUTTON";
  73. }
  74.  
  75. //
  76. // responds to an incoming BN_CLICKED message.
  77. //
  78. // need to see if it's checked because Windows generates two BN_CLICKED
  79. // messages on keyboard input such as up arrow(but only one on mouse input),
  80. // and we should only handle the one after it's checked
  81. //
  82. void
  83. TRadioButton::BNClicked()
  84. {
  85.   if (GetCheck())
  86.     TCheckBox::BNClicked();
  87.  
  88.   else
  89.     DefaultProcessing();
  90. }
  91.  
  92. #endif
  93. #if !defined(SECTION) || SECTION == 2
  94.  
  95. IMPLEMENT_STREAMABLE1(TRadioButton, TCheckBox);
  96.  
  97. #if !defined(BI_NO_OBJ_STREAMING)
  98.  
  99. //
  100. // reads an instance of TRadioButton from the passed ipstream
  101. //
  102. void*
  103. TRadioButton::Streamer::Read(ipstream& is, uint32 /*version*/) const
  104. {
  105.   ReadBaseObject((TCheckBox*)GetObject(), is);
  106.   return GetObject();
  107. }
  108.  
  109. //
  110. // writes the TRadioButton to the passed opstream
  111. //
  112. void
  113. TRadioButton::Streamer::Write(opstream& os) const
  114. {
  115.   WriteBaseObject((TCheckBox*)GetObject(), os);
  116. }
  117. #endif  // if !defined(BI_NO_OBJ_STREAMING)
  118.  
  119. #endif
  120.